package com.client.rule;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.shared.rule.TypeCible;

public class NewDialogBox extends DialogBox {

	private ListBox listCible = new ListBox();
	
	public NewDialogBox() {
		setText("Parametre du nouveau systeme");
		setWidth("250px");
		setHeight("100px");
		for(TypeCible type : TypeCible.values()) listCible.addItem(type.toString());
		
		VerticalPanel mainPanel = new VerticalPanel();		
		mainPanel.setWidth("250px");
		mainPanel.setHeight("100px");
		mainPanel.setSpacing(5);
		
		HorizontalPanel inputPanel =  new HorizontalPanel();
		inputPanel.setSpacing(5);
		mainPanel.add(inputPanel);
		
		inputPanel.add(new Label("Cible :"));
		inputPanel.add(listCible);
		
		Button validateButton = new Button();
		validateButton.setText("Valider");
		validateButton.addClickHandler(new ClickHandler() {
			
			public void onClick(ClickEvent event) {
				NewDialogBox.this.hide();				
			}
		});
		mainPanel.add(validateButton);
		setWidget(mainPanel);
		
		
	}
	
	public String getSelectedCible(){
		return listCible.getItemText(listCible.getSelectedIndex());
	}
}
